package itheima.d03;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

//创建线程的第三种方式：实现Callable接口
public class TheadTest3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<String> target = new MyCallable(100);
        FutureTask<String>f1=new FutureTask<>(target);
        Thread t1 = new Thread(f1);
        t1.start();

        Callable<String> target2 = new MyCallable(200);
        FutureTask<String>f2=new FutureTask<>(target2);
        Thread t2 = new Thread(f2);
        t2.start();

        System.out.println(f1.get());

        System.out.println(f2.get());


    }
}
